import React, { useState } from "react";
import { DatePicker } from "antd";
function Myspace_myspace() {
  const {RangePicker}  = DatePicker;
  const [isshow, setisshow] = useState(false);
const [selectedRanger, setSelectedRanger] = useState('添加时间'); // 用于存储用户选择的时间区间
const [selectedRange, setSelectedRange] = useState([])
  const onclick = () => {
    setisshow(true);
  };
  const handleRangeChange = (dates, dateStrings) => {
        // dates是选择的日期对象数组，dateStrings是对应格式化后的字符串数组
        setSelectedRange(dateStrings);
    };
  return (
    <div>
      <p onClick={onclick}>{selectedRanger}
        {selectedRange.length>0 ? <span>{selectedRange[0]} - {selectedRange[1]}</span> : '' }
        </p>
      <div>{isshow && <RangePicker onChange={handleRangeChange} />}</div>
    </div>
  );
}

export default Myspace_myspace;
